package com.gzpi.hwgggh.controller;

import com.alibaba.fastjson.JSON;
import com.gzpi.hwgggh.entity.DWG;
import com.gzpi.hwgggh.entity.GGP;
import com.gzpi.hwgggh.service.DWGService;
import com.gzpi.hwgggh.sysenum.EnumErrorCode;
import com.gzpi.hwgggh.utils.Result;
import com.gzpi.hwgggh.vo.SearchConditionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @date : 2021-01-12 10:58
 **/
@RequestMapping("/DWG")
@RestController
@CrossOrigin
public class DWGController {

    @Autowired
    private DWGService dwgService;

    /**
     * 获取规划点集合
     * @param searchConditionVo
     * @return
     */
    @RequestMapping(value = "/getDWGList.do")
    public Result getDWGList(SearchConditionVo searchConditionVo){
        try {
            return dwgService.selectDWGList(searchConditionVo);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.createError(EnumErrorCode.ERROR_SYSTEM_UNKNOWN.toString());
        }
    }

    /**
     * 单个查询点位信息和广告牌信息
     * @param id
     * @param num
     * @return
     */
    @RequestMapping(value = "/getGHDW.do")
    public Result getDWG(String id,String num){
        try {
            return dwgService.selectDWG(id,num);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.createError(EnumErrorCode.ERROR_SYSTEM_UNKNOWN.toString());
        }
    }

    /**
     * 编辑点位信息
     * @param files
     * @param dwgJson
     * @param dwxJson
     * @param request
     * @return
     */
    @RequestMapping(value = "/editDWG.do",method = RequestMethod.POST)
    public Result editDWG(@RequestParam(value = "dwtpFiles",required = false) MultipartFile[] files,@RequestParam("dwxJson") String dwxJson, HttpServletRequest request){
        try {
            return dwgService.updateDWG(files,dwxJson,request);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.createError(EnumErrorCode.ERROR_MESSAGE.toString(e.toString()));
        }
    }


}
